<?php


namespace app\common\validate;

class UsersValidate extends CommonValidate
{
    protected $rule  = [
        'token|code'                  => 'require|length:16,64',
        'code|code'                   => 'require|length:16,64',
        'iv|iv'                       => 'require|length:10,64',
        'encryptedData|encryptedData' => 'require|length:10,1500',
        'mobile_number|手机号'           => 'require',
        'password|密码'                 => 'require|length:6,20|notContainsChinese',
        'old_password|旧密码'            => 'require|length:6,20|notContainsChinese',
        'new_password|新密码'            => 'require|length:6,20|notContainsChinese',
        'pid|推荐人ID'                   => 'integer|between:1,100000000',
        //'repassword'    => 'require|confirm:password',
    ];
    protected $scene = [
        'loginAdmin'  => [
            'mobile_number',
            'password',
        ],
        'register'    => [
            'mobile_number',
            'password',
        ],
        'putPassword' => [
            'old_password',
            'new_password',
        ],
    ];

    protected function sceneLoginMpMini()
    {
        return $this->only(
            [
                'code',
                'iv',
                'encryptedData',
                'pid',
            ]
        )->remove('iv', 'require')->remove('encryptedData', 'require');
    }
    //
    //    protected function sceneRegisterMini()
    //    {
    //        return $this->only([
    //            'iv',
    //            'encryptedData',
    //        ]);
    //    }
}